<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数求阶乘</title>
</head>
<body>
<script>
function getJC(n) {
    if (n === 0 || n === 1) {
        return 1;
    } else {
        var result = 1;
        for (var i = 2; i <= n; i++) {
            result *= i;
        }
        return result;
    }
}

function getSum(a) {
    var sum = 0;
    for (var i = 1; i <= a; i++) {
        sum += getJC(i);
    }
    return sum;
}

var factorialOf3 = getJC(3);
console.log("3 的阶乘是", factorialOf3);

var sumOfFactorials = getSum(3);
console.log("3的阶乘累加和是", sumOfFactorials);
</script>

</body>
</html>